#include <iostream>
#include "basic/basic.h"
#include "gc/gc.h"

///////////////////////////
class Base{
public:
	Base():val_(0){
		std::cout << "Deliver::Base" << std::endl;
	}
	virtual ~Base(){
		std::cout << "Deliver::~Base" << std::endl;
	}

	virtual void print(){
		std::cout << "Base::print" << std::endl;
	};
private:
	int val_;
};
class Deliver : public Base{
public:
	Deliver(){
		std::cout << "Deliver::Deliver" << std::endl;
	}
	virtual ~Deliver(){
		std::cout << "Deliver::~Deliver" << std::endl;
	}

	virtual void print(){
		std::cout << "Deliver::print" << std::endl;
	};
};
class DeliverEx : public Base, public eyas::gc::enable_memory_pool<DeliverEx>{
public:
	DeliverEx(){
		std::cout << "Deliver::Deliver" << std::endl;
	}
	virtual ~DeliverEx(){
		std::cout << "Deliver::~Deliver" << std::endl;
	}

	virtual void print(){
		std::cout << "Deliver::print" << std::endl;
	};
};

int main() {
	typedef boost::shared_ptr<Base> BasePtr;
	typedef boost::shared_ptr<Deliver> DeliverPtr;
	clock_t clk = 0;
	clock_t clk2 = 0;
	void* mem = 0;

	eyas::gc::init();

	clk = ::clock();
	for(int i=0; i<500000; i++){
		DeliverPtr dptr = eyas::gc::create_new<Deliver>();
		DeliverPtr dptr2 = eyas::gc::create_new<Deliver>();
		DeliverPtr dptr3 = eyas::gc::create_new<Deliver>();

		dptr->print();
		dptr2->print();
		dptr3->print();
	}
	getchar();
	std::cout << "Enter exit the test." << std::endl;
	getchar();
	return 0;
}
